/**
 * Created by zeopean on 2015/10/16.
 */
var page = 1 ;

$(function(){
    /** 初始化ajax */
    jQuery.ajaxSetup({
        case:false,
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

    $(document).on('click' ,'.more_bar' , function(){
        var stop = true;
        if(stop==true){
            stop=false;

            $.ajax({
                type:"get",
                url:getMore,
                dataType:"json",
                data:{'page':page},
                success:function(obj){
                    setTimeout(function(){
                        if (obj.level == "success") {
                            showMore(obj.data);
                        }
                    },500);
                    stop = true;
                    page = page + 1;
                }
            });
        }
    });
});


function showMore(investors) {
    var HtmlAll='';
    for (var i = 0; i < investors.length; i++) {
        if (investors[i] !== 'undefined') {

            var HTMLInitData = '<li><dl><dt><a href="'+getDetailById+investors[i].id+'"><img src="'+showPhoto+investors[i].id+'" /></a><p>'
                +'</dt><dd class="commpany"><p><a href="#"><strong>'
                +investors[i].userInfo.realname
                +'</strong></a></p>'
                +investors[i].userInfo.user_desc
                +'</p></dd><dd class="list"><div class="list_content"><p class="stage"><em class="reveal">投资领域</em><em class="floatR">';
            var fieldStr = '' ;
            if(fields = investors[i].fields){
                for(var m in fields){
                    fieldStr += fields[m]+'<br>';
                }
            }else{
                fieldStr = '暂无数据';
            }

            HTMLInitData += fieldStr + '</em></p><p class="type"><em class="reveal">投资金额</em><em class="floatR">'
                +investors[i].account
                +'</em></p><p class="address"><em class="reveal">投资案例</em><em  class="floatR">' ;
            var projectsStr = '暂无投资项目' ;
            if(projects = investors[i].projects){
                for(var n in projects){
                    projectsStr += projects[n].project_name + '&nbsp;';
                }
            }
            if(projectsStr == '') projectsStr = '暂无投资项目' ;
            HTMLInitData += projectsStr+'</em></p><p class="member"><button class="reveal" data="'+investors[i].id+'">提交项目</button></p>'
                +'</div></dd></dl></li>';

        }
        HtmlAll += HTMLInitData;
    }

    var onceStr = $(".content ul").html();
    $(".content ul").html(onceStr+HtmlAll);
}

function init(){}